%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/v4/relation-head-tail"
    Bucket0("Bucket 0 (root)<br /><br />1: 110, 114, 118<br />ᐳ: 6, 9, 10, 122, 123, 11, 48, 54<br />2: 15, 102, 106<br />ᐳ: Access[119]<br />3: PgSelect[8], Connection[17]<br />ᐳ: 103, 107, 111, 115<br />4: Connection[12], ConnectionItems[22]<br />5: ConnectionItems[19]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 12, 19, 122, 103, 107, 111, 115<br /><br />ROOT Connectionᐸ8ᐳ[12]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 17, 22, 119<br /><br />ROOT Connectionᐸ15ᐳ[17]"):::bucket
    Bucket5("Bucket 5 (listItem)<br />Deps: 122, 103, 107, 111, 115<br /><br />ROOT __Item{5}ᐸ19ᐳ[25]"):::bucket
    Bucket6("Bucket 6 (listItem)<br />Deps: 119<br /><br />ROOT __Item{6}ᐸ22ᐳ[27]"):::bucket
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 26, 122, 103, 25, 107, 111, 115<br /><br />ROOT PgSelectSingle{5}ᐸpersonᐳ[26]<br />1: <br />ᐳ: 29, 31, 104, 108, 112, 116, 105, 109, 113, 117<br />2: 40, 53, 59, 64<br />3: 66, 72, 75, 78"):::bucket
    Bucket8("Bucket 8 (nullableBoundary)<br />Deps: 28, 119, 27<br /><br />ROOT PgSelectSingle{6}ᐸcompound_keyᐳ[28]<br />1: <br />ᐳ: 30, 32, 120, 121<br />2: Connection[46]<br />3: ConnectionItems[69]"):::bucket
    Bucket14("Bucket 14 (listItem)<br /><br />ROOT __Item{14}ᐸ66ᐳ[81]"):::bucket
    Bucket15("Bucket 15 (listItem)<br /><br />ROOT __Item{15}ᐸ69ᐳ[83]"):::bucket
    Bucket16("Bucket 16 (listItem)<br /><br />ROOT __Item{16}ᐸ72ᐳ[85]"):::bucket
    Bucket17("Bucket 17 (listItem)<br /><br />ROOT __Item{17}ᐸ75ᐳ[87]"):::bucket
    Bucket18("Bucket 18 (listItem)<br /><br />ROOT __Item{18}ᐸ78ᐳ[89]"):::bucket
    Bucket19("Bucket 19 (nullableBoundary)<br />Deps: 82<br /><br />ROOT PgSelectSingle{14}ᐸpostᐳ[82]"):::bucket
    Bucket20("Bucket 20 (nullableBoundary)<br />Deps: 84<br /><br />ROOT PgSelectSingle{15}ᐸforeign_keyᐳ[84]"):::bucket
    Bucket21("Bucket 21 (nullableBoundary)<br />Deps: 86<br /><br />ROOT PgSelectSingle{16}ᐸpostᐳ[86]"):::bucket
    Bucket22("Bucket 22 (nullableBoundary)<br />Deps: 88<br /><br />ROOT PgSelectSingle{17}ᐸcompound_keyᐳ[88]"):::bucket
    Bucket23("Bucket 23 (nullableBoundary)<br />Deps: 90<br /><br />ROOT PgSelectSingle{18}ᐸcompound_keyᐳ[90]"):::bucket
    end
    Bucket0 --> Bucket1 & Bucket2
    Bucket1 --> Bucket5
    Bucket2 --> Bucket6
    Bucket5 --> Bucket7
    Bucket6 --> Bucket8
    Bucket7 --> Bucket14 & Bucket16 & Bucket17 & Bucket18
    Bucket8 --> Bucket15
    Bucket14 --> Bucket19
    Bucket15 --> Bucket20
    Bucket16 --> Bucket21
    Bucket17 --> Bucket22
    Bucket18 --> Bucket23

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸpersonᐳ"]]:::plan
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    PgSelectInlineApply102["PgSelectInlineApply[102∈0] ➊<br />More deps:<br />- Constantᐸ2ᐳ[122]"]:::plan
    PgSelectInlineApply106["PgSelectInlineApply[106∈0] ➊"]:::plan
    PgSelectInlineApply110["PgSelectInlineApply[110∈0] ➊"]:::plan
    PgSelectInlineApply114["PgSelectInlineApply[114∈0] ➊"]:::plan
    Object11 & PgSelectInlineApply102 & PgSelectInlineApply106 & PgSelectInlineApply110 & PgSelectInlineApply114 --> PgSelect8
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    PgSelect15[["PgSelect[15∈0] ➊<br />ᐸcompound_keyᐳ"]]:::plan
    PgSelectInlineApply118["PgSelectInlineApply[118∈0] ➊"]:::plan
    Object11 & PgSelectInlineApply118 --> PgSelect15
    __InputObject48{{"__InputObject[48∈0] ➊<br />More deps:<br />- Constantᐸundefinedᐳ[6]<br />- Constantᐸ'Large bet on myself in round one.'ᐳ[123]"}}:::plan
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    Connection12[["Connection[12∈0] ➊<br />ᐸ8ᐳ"]]:::plan
    PgSelect8 --> Connection12
    Connection17[["Connection[17∈0] ➊<br />ᐸ15ᐳ"]]:::plan
    PgSelect15 --> Connection17
    ConnectionItems19[["ConnectionItems[19∈0] ➊"]]:::plan
    Connection12 --> ConnectionItems19
    ConnectionItems22[["ConnectionItems[22∈0] ➊"]]:::plan
    Connection17 --> ConnectionItems22
    ApplyInput54{{"ApplyInput[54∈0] ➊"}}:::plan
    __InputObject48 --> ApplyInput54
    Access103{{"Access[103∈0] ➊<br />ᐸ8.m.subqueryDetailsFor36ᐳ"}}:::plan
    PgSelect8 --> Access103
    ApplyInput54 --> PgSelectInlineApply106
    Access107{{"Access[107∈0] ➊<br />ᐸ8.m.subqueryDetailsFor51ᐳ"}}:::plan
    PgSelect8 --> Access107
    Access111{{"Access[111∈0] ➊<br />ᐸ8.m.subqueryDetailsFor57ᐳ"}}:::plan
    PgSelect8 --> Access111
    Access115{{"Access[115∈0] ➊<br />ᐸ8.m.subqueryDetailsFor62ᐳ"}}:::plan
    PgSelect8 --> Access115
    Access119{{"Access[119∈0] ➊<br />ᐸ15.m.subqueryDetailsFor42ᐳ"}}:::plan
    PgSelect15 --> Access119
    __Item25[/"__Item[25∈5]<br />ᐸ19ᐳ"\]:::itemplan
    ConnectionItems19 ==> __Item25
    PgSelectSingle26{{"PgSelectSingle[26∈5]<br />ᐸpersonᐳ"}}:::plan
    __Item25 --> PgSelectSingle26
    __Item27[/"__Item[27∈6]<br />ᐸ22ᐳ"\]:::itemplan
    ConnectionItems22 ==> __Item27
    PgSelectSingle28{{"PgSelectSingle[28∈6]<br />ᐸcompound_keyᐳ"}}:::plan
    __Item27 --> PgSelectSingle28
    Connection40[["Connection[40∈7]<br />ᐸ105ᐳ<br />More deps:<br />- Constantᐸ2ᐳ[122]"]]:::plan
    Lambda105{{"Lambda[105∈7]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda105 --> Connection40
    List104{{"List[104∈7]<br />ᐸ103,25ᐳ"}}:::plan
    Access103 & __Item25 --> List104
    List108{{"List[108∈7]<br />ᐸ107,25ᐳ"}}:::plan
    Access107 & __Item25 --> List108
    List112{{"List[112∈7]<br />ᐸ111,25ᐳ"}}:::plan
    Access111 & __Item25 --> List112
    List116{{"List[116∈7]<br />ᐸ115,25ᐳ"}}:::plan
    Access115 & __Item25 --> List116
    PgClassExpression29{{"PgClassExpression[29∈7]<br />ᐸ__person__.”id”ᐳ"}}:::plan
    PgSelectSingle26 --> PgClassExpression29
    PgClassExpression31{{"PgClassExpression[31∈7]<br />ᐸ__person__...full_name”ᐳ"}}:::plan
    PgClassExpression29 o--o PgClassExpression31
    Connection53[["Connection[53∈7]<br />ᐸ109ᐳ"]]:::plan
    Lambda109{{"Lambda[109∈7]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda109 --> Connection53
    Connection59[["Connection[59∈7]<br />ᐸ113ᐳ"]]:::plan
    Lambda113{{"Lambda[113∈7]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda113 --> Connection59
    Connection64[["Connection[64∈7]<br />ᐸ117ᐳ"]]:::plan
    Lambda117{{"Lambda[117∈7]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda117 --> Connection64
    ConnectionItems66[["ConnectionItems[66∈7]"]]:::plan
    Connection40 --> ConnectionItems66
    ConnectionItems72[["ConnectionItems[72∈7]"]]:::plan
    Connection53 --> ConnectionItems72
    ConnectionItems75[["ConnectionItems[75∈7]"]]:::plan
    Connection59 --> ConnectionItems75
    ConnectionItems78[["ConnectionItems[78∈7]"]]:::plan
    Connection64 --> ConnectionItems78
    List104 --> Lambda105
    List108 --> Lambda109
    List112 --> Lambda113
    List116 --> Lambda117
    List120{{"List[120∈8]<br />ᐸ119,27ᐳ"}}:::plan
    Access119 & __Item27 --> List120
    PgClassExpression30{{"PgClassExpression[30∈8]<br />ᐸ__compound...rson_id_1”ᐳ"}}:::plan
    PgSelectSingle28 --> PgClassExpression30
    PgClassExpression32{{"PgClassExpression[32∈8]<br />ᐸ__compound...rson_id_2”ᐳ"}}:::plan
    PgClassExpression30 o--o PgClassExpression32
    Connection46[["Connection[46∈8]<br />ᐸ121ᐳ"]]:::plan
    Lambda121{{"Lambda[121∈8]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda121 --> Connection46
    ConnectionItems69[["ConnectionItems[69∈8]"]]:::plan
    Connection46 --> ConnectionItems69
    List120 --> Lambda121
    __Item81[/"__Item[81∈14]<br />ᐸ66ᐳ"\]:::itemplan
    ConnectionItems66 ==> __Item81
    PgSelectSingle82{{"PgSelectSingle[82∈14]<br />ᐸpostᐳ"}}:::plan
    __Item81 --> PgSelectSingle82
    __Item83[/"__Item[83∈15]<br />ᐸ69ᐳ"\]:::itemplan
    ConnectionItems69 ==> __Item83
    PgSelectSingle84{{"PgSelectSingle[84∈15]<br />ᐸforeign_keyᐳ"}}:::plan
    __Item83 --> PgSelectSingle84
    __Item85[/"__Item[85∈16]<br />ᐸ72ᐳ"\]:::itemplan
    ConnectionItems72 ==> __Item85
    PgSelectSingle86{{"PgSelectSingle[86∈16]<br />ᐸpostᐳ"}}:::plan
    __Item85 --> PgSelectSingle86
    __Item87[/"__Item[87∈17]<br />ᐸ75ᐳ"\]:::itemplan
    ConnectionItems75 ==> __Item87
    PgSelectSingle88{{"PgSelectSingle[88∈17]<br />ᐸcompound_keyᐳ"}}:::plan
    __Item87 --> PgSelectSingle88
    __Item89[/"__Item[89∈18]<br />ᐸ78ᐳ"\]:::itemplan
    ConnectionItems78 ==> __Item89
    PgSelectSingle90{{"PgSelectSingle[90∈18]<br />ᐸcompound_keyᐳ"}}:::plan
    __Item89 --> PgSelectSingle90
    PgClassExpression91{{"PgClassExpression[91∈19]<br />ᐸ__post__.”headline”ᐳ"}}:::plan
    PgSelectSingle82 --> PgClassExpression91
    PgClassExpression96{{"PgClassExpression[96∈19]<br />ᐸ__post__.”author_id”ᐳ"}}:::plan
    PgClassExpression91 o--o PgClassExpression96
    PgClassExpression92{{"PgClassExpression[92∈20]<br />ᐸ__foreign_...person_id”ᐳ"}}:::plan
    PgSelectSingle84 --> PgClassExpression92
    PgClassExpression97{{"PgClassExpression[97∈20]<br />ᐸ__foreign_...und_key_1”ᐳ"}}:::plan
    PgClassExpression92 o--o PgClassExpression97
    PgClassExpression101{{"PgClassExpression[101∈20]<br />ᐸ__foreign_...und_key_2”ᐳ"}}:::plan
    PgClassExpression97 o--o PgClassExpression101
    PgClassExpression93{{"PgClassExpression[93∈21]<br />ᐸ__post__.”headline”ᐳ"}}:::plan
    PgSelectSingle86 --> PgClassExpression93
    PgClassExpression98{{"PgClassExpression[98∈21]<br />ᐸ__post__.”author_id”ᐳ"}}:::plan
    PgClassExpression93 o--o PgClassExpression98
    PgClassExpression94{{"PgClassExpression[94∈22]<br />ᐸ__compound...rson_id_1”ᐳ"}}:::plan
    PgSelectSingle88 --> PgClassExpression94
    PgClassExpression99{{"PgClassExpression[99∈22]<br />ᐸ__compound...rson_id_2”ᐳ"}}:::plan
    PgClassExpression94 o--o PgClassExpression99
    PgClassExpression95{{"PgClassExpression[95∈23]<br />ᐸ__compound...rson_id_1”ᐳ"}}:::plan
    PgSelectSingle90 --> PgClassExpression95
    PgClassExpression100{{"PgClassExpression[100∈23]<br />ᐸ__compound...rson_id_2”ᐳ"}}:::plan
    PgClassExpression95 o--o PgClassExpression100

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Connection12,PgSelect15,Connection17,ConnectionItems19,ConnectionItems22,__InputObject48,ApplyInput54,PgSelectInlineApply102,Access103,PgSelectInlineApply106,Access107,PgSelectInlineApply110,Access111,PgSelectInlineApply114,Access115,PgSelectInlineApply118,Access119 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2 bucket2
    classDef bucket5 stroke:#7fff00
    class Bucket5,__Item25,PgSelectSingle26 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,__Item27,PgSelectSingle28 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,PgClassExpression29,PgClassExpression31,Connection40,Connection53,Connection59,Connection64,ConnectionItems66,ConnectionItems72,ConnectionItems75,ConnectionItems78,List104,Lambda105,List108,Lambda109,List112,Lambda113,List116,Lambda117 bucket7
    classDef bucket8 stroke:#dda0dd
    class Bucket8,PgClassExpression30,PgClassExpression32,Connection46,ConnectionItems69,List120,Lambda121 bucket8
    classDef bucket14 stroke:#a52a2a
    class Bucket14,__Item81,PgSelectSingle82 bucket14
    classDef bucket15 stroke:#ff00ff
    class Bucket15,__Item83,PgSelectSingle84 bucket15
    classDef bucket16 stroke:#f5deb3
    class Bucket16,__Item85,PgSelectSingle86 bucket16
    classDef bucket17 stroke:#696969
    class Bucket17,__Item87,PgSelectSingle88 bucket17
    classDef bucket18 stroke:#00bfff
    class Bucket18,__Item89,PgSelectSingle90 bucket18
    classDef bucket19 stroke:#7f007f
    class Bucket19,PgClassExpression91,PgClassExpression96 bucket19
    classDef bucket20 stroke:#ffa500
    class Bucket20,PgClassExpression92,PgClassExpression97,PgClassExpression101 bucket20
    classDef bucket21 stroke:#0000ff
    class Bucket21,PgClassExpression93,PgClassExpression98 bucket21
    classDef bucket22 stroke:#7fff00
    class Bucket22,PgClassExpression94,PgClassExpression99 bucket22
    classDef bucket23 stroke:#ff1493
    class Bucket23,PgClassExpression95,PgClassExpression100 bucket23

